import 'package:boss/color_constant.dart';
import 'package:boss/models/order_page_data.dart';
import 'package:boss/textStyle/text_style.dart';
import 'package:boss/ui/widget/custom_divier.dart';
import 'package:boss/ui/widget/shadow_radius_card.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';

class OrderItem extends StatelessWidget {
  final VoidCallback onTap;
  final Order data;

  const OrderItem({
    Key key,
    @required this.data,
    this.onTap,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: ShadowRadiusCard(
        height: 210.w,
        padding: EdgeInsets.only(
          left: 20.w,
          right: 20.w,
        ),
        margin: EdgeInsets.symmetric(
          vertical: 15.w,
        ),
        child: Column(
          children: <Widget>[
            Container(
              height: 82.w,
              padding: EdgeInsets.only(
                top: 7.w,
              ),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  Expanded(
                    child: Row(
                      textBaseline: TextBaseline.alphabetic,
                      crossAxisAlignment: CrossAxisAlignment.end,
                      children: <Widget>[
                        Text(
                          '${data.orderStatusText}',
                          style: TextStyle(
                            color: ColorConstant.ff5770f6,
                          ),
                          strutStyle: StrutStyle(
                            fontSize: 32.sp,
                            height: 1,
                          ),
                        ),
                        Expanded(
                          child: Container(
                            margin: EdgeInsets.only(
                              left: 20.w,
                            ),
                            child: Text(
                              '${data.payTime ?? ''}',
                              style: TextStyle(color: ColorConstant.ff99),
                              maxLines: 1,
                              overflow: TextOverflow.ellipsis,
                              strutStyle: StrutStyle(
                                fontSize: 24.sp,
                                height: 1,
                              ),
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                  Text(
                    '服务员：${data.waiterName}',
                    style: TextStyleConstant().normal_3_24,
                  ),
                ],
              ),
            ),
            CustomDivider(),
            Expanded(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      Text(
                        '${data.unionOrderId}',
                        style: TextStyleConstant().normal_1_28,
                      ),
                      Text(
                        '${data.tableName}',
                        style: TextStyleConstant().normal_1_28,
                      ),
                    ],
                  ),
                  Row(
                    children: <Widget>[
                      Expanded(
                        child: Row(
                          children: <Widget>[
                            Text(
                              '实收金额',
                              style: TextStyleConstant().normal_3_24,
                            ),
                            Container(
                                margin: EdgeInsets.only(
                                  left: 13.w,
                                ),
                                child: Text(
                                  '${AmountUtil.price2String(data.totalFee)}',
                                  style: TextStyleConstant().normal_1_28,
                                )),
                          ],
                        ),
                      ),
                      Expanded(
                        child: Text(
                          '${data.payTypeName}',
                          style: TextStyleConstant().normal_3_24,
                          maxLines: 1,
                          overflow: TextOverflow.ellipsis,
                        ),
                      ),
                    ],
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
